﻿@** Copyright 2013 Seven Spikes Ltd. All rights reserved. (http://www.nop-templates.com)
* http://www.nop-templates.com/t/licensinginfo
*@

@model SevenSpikes.Nop.Plugins.AjaxCart.Models.AjaxCartButtonsModel

@if (Model.AddProductToCartAjaxButtonModels.Count > 0)
{
    if (!Model.IsAjax)
    {
        Html.AppendCssFileParts("~/Plugins/SevenSpikes.Nop.Plugins.AjaxCart/Themes/" + Model.NopAjaxCartSettingsModel.Theme + "/Content/styles.css");

        Html.AppendScriptParts("~/Plugins/SevenSpikes.Nop.Plugins.AjaxCart/Scripts/jquery.json-2.2.min.js");
        Html.AppendScriptParts("~/Plugins/SevenSpikes.Nop.Plugins.AjaxCart/Scripts/AjaxCart.min.js");

        Html.AppendScriptParts("~/Plugins/SevenSpikes.Core/Scripts/kendo.public.min.js");
    }

    foreach (var button in Model.AddProductToCartAjaxButtonModels)
    {
    <div class="ajax-cart-button-wrapper" data-productId="@button.ProductId" data-isProductPage="@button.IsProductPage.ToString().ToLower()">
        @if (button.IsProductPage)
        {
            <input type="button" value="@button.ButtonValue" class="button-1 add-to-cart-button nopAjaxCartProductVariantAddToCartButton" data-productId="@button.ProductId" />
        }
        else
        {
            if (Model.NopAjaxCartSettingsModel.EnableProductQuantityTextBox)
            {
            <input id="@String.Concat("productQuantity", @button.ProductId)" type="text" class="productQuantityTextBox" value="@button.DefaultProductMinimumQuantity" />
            }

            <input type="button" value="@button.ButtonValue" class="button-2 product-box-add-to-cart-button nopAjaxCartProductListAddToCartButton" data-productId="@button.ProductId"/>
        }

        @if (!Model.IsAjax)
        {
            @Html.Hidden("addProductVariantToCartUrl", Url.Action("AddProductFromProductDetailsPageToCartAjax", "NopAjaxCartShoppingCart"))
            @Html.Hidden("addProductToCartUrl", Url.Action("AddProductToCartAjax", "NopAjaxCartShoppingCart"))
            @Html.Hidden("miniShoppingCartUrl", Url.Action("MiniShoppingCart", "NopAjaxCartShoppingCart"))
            @Html.Hidden("flyoutShoppingCartUrl", Url.Action("NopAjaxCartFlyoutShoppingCart", "NopAjaxCartShoppingCart"))
            @Html.Hidden("checkProductAttributesUrl", Url.Action("CheckIfProductOrItsAssociatedProductsHasAttributes", "NopAjaxCartCatalog"))
            @Html.Hidden("getMiniProductDetailsViewUrl", Url.Action("GetMiniProductDetailsView", "NopAjaxCartCatalog"))
            @Html.Hidden("flyoutShoppingCartPanelSelector", Html.Encode(Model.NopAjaxCartSettingsModel.FlyoutCartPanelSelector))
            @Html.Hidden("shoppingCartMenuLinkSelector", Html.Encode(Model.NopAjaxCartSettingsModel.ShoppingCartMenuLinkSelector))
            @Html.Partial("AdditionalPanelsToUpdate")
        }
    </div>   
    }
}